﻿using System;
using System.Diagnostics;

namespace JTActiveSafety.Gateway.Internal
{
    public class HostRuntime
    {
        private static readonly Stopwatch CuttCount = new();

        static HostRuntime() {
            Start();
        }

        private static void Start() {
            if (!CuttCount.IsRunning)
            {
                CuttCount.Start();
            }
        }

        /// <summary>
        /// 获取系统启动时间的秒数
        /// </summary>
        public static double TickSeconds
        {
            get
            {
                return Math.Ceiling(CuttCount.Elapsed.TotalSeconds);
            }
        }

        /// <summary>
        /// 获取系统启动时间的毫秒数
        /// </summary>
        /// <returns>启动毫秒数</returns>
        public static double TickMilliseconds
        {
            get
            {
                return Math.Ceiling(CuttCount.Elapsed.TotalMilliseconds);
            }
        }
    }
}
